<%-- 
    Document   : payment
    Created on : Feb 9, 2013, 9:39:39 PM
    Author     : SONY
--%>

<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page import="model.ShoppingCart"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<%
    String cardnumber = "";
    String cardholder = "";
    String total = "0";
    ShoppingCart shopping_cart = (ShoppingCart) session.getAttribute("shopping_cart");
    if(!shopping_cart.getAllItemCart().isEmpty()) {
        total = String.valueOf(shopping_cart.TotalPrice());
    }
    if(request.getAttribute("cardnumber") != null) {
        cardnumber = request.getAttribute("cardnumber").toString();
    }
    if(request.getAttribute("cardholder") != null) {
        cardholder = request.getAttribute("cardholder").toString();
    }
    String fullname = "";
    String address = "";
    String phone = "";
    if(request.getAttribute("Name") != null) {
        fullname = request.getAttribute("Name").toString();
    }
    if(request.getAttribute("Address") != null) {
        address = request.getAttribute("Address").toString();
    }
    if(request.getAttribute("Phone") != null) {
        phone = request.getAttribute("Phone").toString();
    }      
%>
<ul>
<% 
if(request.getAttribute("errorMsgs") != null) {
    List errorMsgs = (List) request.getAttribute("errorMsgs");
    Iterator errorMsg = errorMsgs.iterator();
    while(errorMsg.hasNext()) { 
        String error = errorMsg.next().toString(); %>
        <i style='color:red'><li><%=error%></li></i>
<% } } %>
</ul>
<br/>
<br/>
<form method="post" action="<c:url value="/nonmember/payment.do" />">
    <fieldset class="register" style="width: 400px;">
        <legend class="lgend">Thông Tin Thẻ</legend>
  <table width="350" border="0">
    <tr>
      <td width="150">Số Thẻ</td>
      <td width="200"><input type="text" class="txtMask" name="cardnumber" style="width: 200px;" value="<%=cardnumber%>" /></td>
    </tr>
    <tr>
      <td>Tên Chủ Thẻ</td>
      <td><input type="text" name="cardholder" class="txtMask" style="width: 200px;" value="<%=cardholder%>" /></td>
    </tr>
    <tr>
      <td>Tổng Tiền Thanh Toán</td>
      <td><input type="text" name="total" class="txtMask" value="<%=total%>" readonly="true" style="text-align: right;width: 200px;"></td>
    </tr>
    <tr>
      <td colspan="2" align=center>
          <input type="hidden" name="fullname" value="<%=fullname%>"/>
          <input type="hidden" name="address" value="<%=address%>"/>
          <input type="hidden" name="phone" value="<%=phone%>"/>
      	<input type="submit" class="btnMask" value='Thanh Toán' style="margin-top: 10px;margin-left: 100px;" />
      </td>
    </tr>
  </table>
    </fieldset>
</form>
<% 
if(((HttpServletRequest) request).getAttribute("notify") != null) {
    String notify = ((HttpServletRequest) request).getAttribute("notify").toString();
    if(notify.length() > 0) { 
        out.println("<script type=\"text/javascript\">");
        out.println("alert(\"" + notify + "\")");
        out.println("</script>");
    }
} %>
